#include "Utils.h"
#include "ListNode.h"
#include "TreeNode.h"
#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Issue263 {
public:
	bool isUgly(int num){
		if (num==0)
			return false;
		while (0==num%2)
			num=num/2;
		while (0==num%3)
			num=num/3;
		while (0==num%5)
			num=num/5;
		return num==1;
	}
};

int main263(){

	Issue263 sol;
	int num;
	while(true)
	{
		cin>>num;
		cout<<sol.isUgly(num)<<endl;
	}

	return 0;
}